<?php


namespace App\Models;


use App\Engine\BaseModel;


/**
 * Class ChartLog
 *
 * @property int $Uid
 * @property int $type
 * @property string|null $message_id
 * @property string|null $message
 * @property string|null $content
 * @property int $created_at
 * @property int $is_delete
 * @property int $updated_at
 * @package App\Models
 */
class ChartLog extends BaseModel
{
    protected $table = 'chart_logs';
    protected $fillable = [
        'message_id',
        'uid',
        'content',
        'msg_type',
        'message',
        'url',
        'cid',
        'is_delete'
    ];

    public function setContentAttribute($value)
    {
        $this->attributes["content"]=json_encode($value!=''?$value:[]);
    }

    public function getContentAttribute($value)
    {
      return $value!=''?json_decode($value,256):"";
    }

    public function custom()
    {
        return $this->belongsTo("App\Models\User","cid","id")->select(["id","nickname","avatar"]);
    }

}
